﻿using System.Text.RegularExpressions;

namespace SharpML.Api.Extensions
{
    public static class Strings
    {
        /// <summary>
        /// Compiled reg-ex for Proper Case
        /// </summary>
        private static Regex ProperCaseRegEx = new Regex( @"(?<!\S)\p{Ll}", RegexOptions.Compiled );

        /// <summary>
        /// Correct Casing So That Each Word Is Capitalized
        /// </summary>
        /// <param name="sz"></param>
        /// <returns></returns>
        public static string ProperCase( this string words )
        {
            return ProperCaseRegEx.Replace( words, letter => letter.Value.ToUpper() );
        }
    }
}
